import request from '@/utils/request'
import { makeFormData, transferFormData } from '@/utils/util'

const clueApi = {
  inquire: 'api/staff_extend/info/list_join', // 教师表格
  quit: '/web/staff/quit', // 离职
  entry: 'web/staff/entry', // 入职
  detail: 'web/staff/base_info', // 教师信息
  submit: '/api/staff_extend/info/add2' // 新增教师
}

export function submitTeacher (params = {}) {
  return request({
    url: clueApi.inquire,
    method: 'get',
    params
  })
}

export function staffQuit (params = {}, data = {}, method = 'post') {
  return request({
    url: clueApi.quit,
    method,
    params,
    data
  })
}

export function getDetailById (data = {}) {
  return request({
    url: clueApi.detail,
    method: 'post',
    data: makeFormData(data)
  })
}

export function submitStaff (data = {}, method = 'post') {
  const formdata = new FormData()
  transferFormData(data, formdata)
  return request({
    url: clueApi.submit,
    method,
    data: formdata
  })
}

export function staffEntry (params = {}, data = {}, method = 'post') {
  return request({
    url: clueApi.entry,
    method,
    params,
    data
  })
}
